package com.smartticket.jeju.repository;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.jdbc.core.support.JdbcDaoSupport;
import org.springframework.stereotype.Repository;

import com.smartticket.jeju.model.User;

public class UserRepositoryImpl{
	
	@Autowired
	private JdbcDaoSupport jdbcDaoSupport;
	
	@Autowired
	@Qualifier("userRowMapper")
	private RowMapper<User> rowMapper;
	

	public void insert(User user) {
		String query = "insert into users values(?, ?, ?, ?, ?, ?)";
		jdbcDaoSupport.getJdbcTemplate().update(query,user.getId(), user.getName(), user.getPw(), user.getPhone(), user.getEmail(), user.getRegion() );
	}


	public List<User> findAll() {
		return jdbcDaoSupport.getJdbcTemplate().query("select * from users", rowMapper);
	}

}
